<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>司机测试页面</title>
    <script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/1.12.4/jquery.min.js" type="application/javascript"></script>
</head>
<body>
    <input placeholder="司机手机号码" id="ipt" value="13503074647" />
    <input placeholder="token" id="token" value="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoxLCJ1bmFtZSI6bnVsbCwicHdkIjpudWxsLCJ0eXBlIjoiZHJpdmVyIiwicGhvbmUiOiIxMzUwMzA3NDY0NyIsImlkTm8iOiI0NTA3MjIxOTg5MDQwNzE1MTEiLCJyZWFsTmFtZSI6IuWImOeOpeW9pCIsImNyZWF0ZWRBdCI6IjIwMjMtMTItMThUMTM6Mjk6MjUuOTYwWiIsInVwZGF0ZWRBdCI6IjIwMjMtMTItMThUMTQ6MjQ6MjUuNTkyWiIsImRsZnJvbnQiOiJodHRwOi8vMTkyLjE2OC41MC4xMDE6MzAwMC91cGxvYWRzL3VwbG9hZDAxNzAyOTA2NTcyNzQyLmpwZyIsImRsYmFjayI6Imh0dHA6Ly8xOTIuMTY4LjUwLjEwMTozMDAwL3VwbG9hZHMvdXBsb2FkMDE3MDI5MDY1OTkwMTguanBnIiwibGljZW5zZSI6Imh0dHA6Ly8xOTIuMTY4LjUwLjEwMTozMDAwL3VwbG9hZHMvdXBsb2FkMDE3MDI5MDY2Njc3NDguanBnIiwiaWRmcm9udCI6Imh0dHA6Ly8xOTIuMTY4LjUwLjEwMTozMDAwL3VwbG9hZHMvdXBsb2FkMDE3MDI5MDkwNjQ2MzAuanBnIiwiaWRiYWNrIjoiaHR0cDovLzE5Mi4xNjguNTAuMTAxOjMwMDAvdXBsb2Fkcy91cGxvYWQwMTcwMjkwOTA3NDU0My5qcGcifSwiaWF0IjoxNzAzNDMyOTcyLCJleHAiOjE3MDM1MTkzNzJ9.ryyIO2U6DVeRG_38-OwcpbD0tBOhrQuSvdUHjDLuEbo" />

    <button id="login">连接</button>
    <hr />
    <input id="orderid" placeholder="订单id" />
    <div>
        <button id="accept">接单</button>
        <button id="cancel">取消订单</button>
    </div>
  
    <script>

         $('#login').click(()=>{
            const phone = $('#ipt').val();
            const token = $("#token").val();
            const sc = new WebSocket(`ws://127.0.0.1:3000/ws?phone=${phone}&type=driver`);
            console.log('尝试连接')
            sc.onopen = (e)=>{
                console.log('链接成功',e)
               
            }
            sc.onmessage = (msg)=>{
                console.log('sc',msg)
            }
            sc.onclose = (e)=>{
                console.log('关闭了',e)
            }
            sc.onerror = (e) => {
                    console.error('连接错误', e)
            }

            $('#accept').click(()=>{
                const orderId = $("#orderid").val();
                sc.send(JSON.stringify({type:' ',payload: { orderId ,token }}))
            })

         })



        

     
    </script>
    
</body>
</html>